package com.huyaanalysisplatform.service.impl;

import com.huyaanalysisplatform.entity.TVideo;
import com.huyaanalysisplatform.entity.TVideoArea;
import com.huyaanalysisplatform.mapper.TVideoAreaMapper;
import com.huyaanalysisplatform.service.TVideoAreaService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Huadi Group 12
 * @since 2021-08-01
 */
@Service
public class TVideoAreaServiceImpl extends ServiceImpl<TVideoAreaMapper, TVideoArea> implements TVideoAreaService {

    @Autowired
    TVideoAreaMapper tVideoAreaMapper;

    @Override
    public Map<String, List<Map<String, Object>>> totalScoreOfVideoAreas() {
          List<TVideoArea> tVideoAreaList = tVideoAreaMapper.allVideoArea();
          List<Map<String,Object>> list  = new ArrayList<>();
          for(TVideoArea tVideoArea : tVideoAreaList){
              Map<String,Object> videoAreaMap = new HashMap<>();
              videoAreaMap.put("area",tVideoArea.getArea());
              videoAreaMap.put("score", tVideoArea.getScore());
              list.add(videoAreaMap);
          }
          Map<String, List<Map<String, Object>>> map = new HashMap<>();
          map.put("data",list);
          return map;
    }
}
